package com.zjitc;


import javax.sql.DataSource;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/7 13:58
 * @description:
 */
@Configuration
@Component
@Import(DataSourceProperties.class)
public class DataSourceConfig {

    @Bean(name = "source")
    public DataSource dataSource(DataSourceProperties DataSourceproperties){
      HikariDataSource dataSource = new HikariDataSource();
      dataSource.setUsername(DataSourceproperties.getUsername());
      dataSource.setPassword(DataSourceproperties.getPassword());
      dataSource.setJdbcUrl(DataSourceproperties.getJdbcurl());
      dataSource.setDriverClassName(DataSourceproperties.getDriver());

      return dataSource;
    }


}
